<template>
  <div class="login-box">
    <lay-json-schema-form :model="form" :schema="schema1" ></lay-json-schema-form>
    <lay-button type="primary" text-align="center" @click="submit1">提交</lay-button>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue';
import { layer } from '@layui/layer-vue'
import {addModels} from "@/api/model";

const form = reactive({
  title: '',
  request_type: '',
  request_content: ''
})

const schema1 = reactive({
  title: {
    label: '咨询问题',
    type: 'input',
    props: {
      type: 'text',
      placeholder: '请输入咨询问题',
    }
  },
  request_type: {
    label: '咨询类型',
    type: 'select',
    props: {
      options: [
        { label: '成绩咨询', value: '1' },
        { label: '院校咨询', value: '2' },
        { label: '专业咨询', value: '3' },
        { label: '录取咨询', value: '4' }
      ],
      placeholder: '请选择咨询问题类型',
    }
  },
  request_content: {
    label: '咨询问题',
    type: 'textarea',
    props: {
      type: 'textarea',
      placeholder: '请输入咨询问题',
    }
  },
})


const submit1 = () => {
  form["tablename"] = "question"
  addModels("question",form).then(res => {
    layer.msg(`添加成功`, { time: 2000 });
    window.location.reload();
  });
}
</script>
<style>
.login-box {
  border: 1px solid #DCDFE6;
  width: 500px;
  margin: 50px auto;
  padding: 35px 35px 15px 35px;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
}

.login-box-title {
  text-align: center;
  margin: 0 auto 40px auto;
  color: #303133;
}
</style>
